package cn.lx.auth.secutity.close;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;

/**
 * @ClassName CloseSecurityConfig
 * @Description: 关闭认证SecurityConfig
 * @Author: 落雪
 * @CreateDate: 2025/7/14 23:27
 * @UpdateUser: 落雪
 * @UpdateDate: 2025/7/14 23:27
 * @UpdateRemark:
 * @Version: 1.0
 */
@Configuration
@ConditionalOnProperty(
        name = {"security.type"},
        havingValue = "hsa-close"
)
public class CloseSecurityConfig extends WebSecurityConfigurerAdapter {


    public CloseSecurityConfig() {
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {

         http.authorizeRequests()
                .antMatchers(new String[]{"/**"})
                .permitAll()
                .anyRequest()
                .authenticated()
                .and()
                .headers()
                .frameOptions()
                 .disable()
                .and()
                 .logout()
                 .and()
                 .csrf()
                 .disable();
    }
}
